from django.db import models

class City(models.Model):
    city_id = models.AutoField(primary_key=True, verbose_name='城市ID')
    city_code = models.CharField(max_length=3, verbose_name='城市代码',null=True, blank=True)
    city_name = models.CharField(max_length=16, verbose_name='城市名称')
    city_lon = models.FloatField(verbose_name='经度')
    city_lat = models.FloatField(verbose_name='纬度')

    class Meta:
        db_table = 'city'  # 对应数据库中的表名
        verbose_name = '城市'  # 在 admin 后台中的单数显示名称
        verbose_name_plural = verbose_name  # 在 admin 后台中的复数显示名称

    def __str__(self):
        return self.city_name
# Create your models here.
# 航空公司
class Airline(models.Model):
    airline_id = models.AutoField(primary_key=True)
    airline_code = models.CharField(max_length=4, blank=True, null=True)
    airline_name = models.CharField(max_length=64, blank=True, null=True)

    def __str__(self):
        return self.airline_name

# 航程
class Itinerary(models.Model):
    itinerary_id = models.AutoField(primary_key=True)
    flight_no = models.CharField(max_length=8, blank=True, null=True)
    airline = models.CharField(max_length=64, blank=True, null=True)
    departure_city = models.CharField(max_length=64, blank=True, null=True)
    departure_airport = models.CharField(max_length=64, blank=True, null=True)
    arrival_city = models.CharField(max_length=64, blank=True, null=True)
    arrival_airport = models.CharField(max_length=64, blank=True, null=True)
    departure_time = models.TimeField(blank=True, null=True)
    departure_date = models.DateField(blank=True, null=True)
    arrival_date = models.DateField(blank=True, null=True)
    arrival_time = models.TimeField(blank=True, null=True)
    price = models.IntegerField(blank=True, null=True)
    flight_type= models.CharField(max_length=32, blank=True, null=True)

    def __str__(self):
        return f"Itinerary {self.itinerary_id} for flight {self.flight_no}"

class PredictInfor(models.Model):
    uid = models.AutoField(primary_key=True)
    departure_city = models.CharField(max_length=64, blank=True, null=True)
    arrival_city = models.CharField(max_length=64, blank=True, null=True)
    airline = models.CharField(max_length=64, blank=True, null=True)
    minprice = models.FloatField(blank=True, null=True)
    price1 = models.FloatField(blank=True, null=True)
    price2 = models.FloatField(blank=True, null=True)
    price3 = models.FloatField(blank=True, null=True)
    price4 = models.FloatField(blank=True, null=True)
    price5 = models.FloatField(blank=True, null=True)
    price6 = models.FloatField(blank=True, null=True)
    price7 = models.FloatField(blank=True, null=True)
    price8 = models.FloatField(blank=True, null=True)
    price9 = models.FloatField(blank=True, null=True)
    price10 = models.FloatField(blank=True, null=True)
    price11 = models.FloatField(blank=True, null=True)
    price12 = models.FloatField(blank=True, null=True)
    price13 = models.FloatField(blank=True, null=True)
    price14 = models.FloatField(blank=True, null=True)
    price15 = models.FloatField(blank=True, null=True)

    def __str__(self):
        return self.uid

class PredictInfordate(models.Model):
    uid = models.AutoField(primary_key=True)
    airline = models.CharField(max_length=64, blank=True, null=True)
    departure_city = models.CharField(max_length=64, blank=True, null=True)
    arrival_city = models.CharField(max_length=64, blank=True, null=True)
    date1 = models.DateField(blank=True, null=True)
    date2 = models.DateField(blank=True, null=True)
    date3 = models.DateField(blank=True, null=True)
    date4 = models.DateField(blank=True, null=True)
    date5 = models.DateField(blank=True, null=True)
    date6 = models.DateField(blank=True, null=True)
    date7 = models.DateField(blank=True, null=True)
    date8 = models.DateField(blank=True, null=True)
    date9 = models.DateField(blank=True, null=True)
    date10 = models.DateField(blank=True, null=True)
    date11 = models.DateField(blank=True, null=True)
    date12 = models.DateField(blank=True, null=True)
    date13 = models.DateField(blank=True, null=True)
    date14 = models.DateField(blank=True, null=True)
    date15 = models.DateField(blank=True, null=True)

    def __str__(self):
        return self.uid